package com.meichis.yndms.room.dao;


import androidx.room.*;

import com.meichis.yndms.model.VisitWorkItem;

import java.util.List;

@Dao
public interface VisitWorkItemDao {
    @Query("SELECT * FROM VisitWorkItem WHERE VisitGUID=:visitGUID ORDER BY WorkTime")
    List<VisitWorkItem> findAll(String visitGUID);

    @Query("SELECT * FROM VisitWorkItem WHERE VisitGUID=:visitGUID AND ProcessCode=:processCode")
    VisitWorkItem find(String visitGUID, String processCode);

    @Query("DELETE FROM VisitWorkItem WHERE VisitGUID=:visitGUID")
    int deleteAll(String visitGUID);

    @Query("DELETE FROM VisitWorkItem WHERE VisitGUID=:visitGUID AND ProcessCode=:processCode")
    int delete(String visitGUID, String processCode);

    @Delete
    int delete(VisitWorkItem... VisitWorkItems);

    @Update
    int update(VisitWorkItem... VisitWorkItems);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insertAll(List<VisitWorkItem> list);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insert(VisitWorkItem... VisitWorkItems);
}
